package javase.io;

import java.io.File;

/**
 * 打印某一目录下所有文件的文件名
 * @author LiShaowen
 * @date 2020/9/7 23:14
 */
public class PrintFIleName {
    public static void printName(int deepth, File file){
        for (int i = 0; i < deepth; i++) {
            System.out.print("-");
        }
        System.out.println(file.getName());
        if (null == file && !file.exists()) {
            return;
        }else if (file.isDirectory()){
            for (File listFile : file.listFiles()) {
                printName(deepth+1,listFile);
            }
        }
    }

    public static void main(String[] args) {
        File file = new File("E:/IDEAProject/java/src/main/java");
        printName(0,file);
    }
}
